package com.mt.common.core.utils;

import com.mt.common.core.config.RabbitMqConfig;
import org.apache.poi.ss.formula.functions.T;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @ClassName: RabbitMqUtil
 * @Description:
 * @Author zhanghong
 * @Date 2022/5/16
 */
@Component
public class RabbitMqUtil {
    @Autowired
    private RabbitTemplate rabbitTemplate;
    Logger logger = LoggerFactory.getLogger(RabbitMqUtil.class);
    public void sendMessage(Object message){
        try {
            rabbitTemplate.convertAndSend(RabbitMqConfig.MSG_EXCHANGE, RabbitMqConfig.MSG_ROUTING_KEY, message);
            logger.info("-------------------消息发送成功----------------------");
        } catch (Exception e) {
            logger.error("-------------------消息发送失败---------------------");
        }
    }
}
